package com.itwlj.init;

import com.itwlj.controller.user.HomeController;
import com.itwlj.service.BannerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

@Component
public class PreloadCache implements ApplicationRunner {

    @Autowired
    private BannerService bannerService;
    @Autowired
    private HomeController homeController;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        // 调用缓存方法进行预热
        bannerService.getByDistributionSite(1);
        bannerService.getByDistributionSite(2);

        homeController.getHomeData();
    }

}
